package com.baboba.rummy.cards;

import java.util.Arrays;
import java.util.LinkedList;

import com.baboba.rummy.shuffler.IShuffler;
import com.baboba.rummy.shuffler.RandomExchangeShuffler;

public class CardFactory {
	
	public static Card[] generateCards(){
		Card[] cards = new Card[106];
		
		for (byte i=0;i<13;i++){
			byte number = (byte)(i + (byte)1);
			cards[i] = new ColorCard(number, Color.Red);
			cards[i+13] = new ColorCard(number, Color.Red);
			cards[i+26] = new ColorCard(number, Color.Blue);
			cards[i+39] = new ColorCard(number, Color.Blue);
			cards[i+52] = new ColorCard(number, Color.Black);
			cards[i+65] = new ColorCard(number, Color.Black);
			cards[i+78] = new ColorCard(number, Color.Orange);
			cards[i+91] = new ColorCard(number, Color.Orange);
		}
		
		
		cards[cards.length-2] = new KingCard();
		cards[cards.length-1] = new KingCard();
		
		return cards;
	}
	
	public static Card[] generateRandomCards(){
		Card[] cards = generateCards();
		IShuffler<Card> shuffler = new RandomExchangeShuffler<Card>();
		shuffler.shuffle(cards);
		return cards;
	}
	
	public static LinkedList<Card> generateRandomCardsAsList(){
		LinkedList<Card> list = new LinkedList<Card>();
		list.addAll(Arrays.asList(generateRandomCards()));
		return list;
	}
}
